package com.xsj.controller;

import com.xsj.service.ComboService;
import com.xsj.vo.Combo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
@CrossOrigin
@Tag(name = "ComboController")
@RestController
@RequestMapping("/combo")
public class ComboController {

    private final ComboService comboService;


    public ComboController(ComboService comboService) {
        this.comboService = comboService;
    }

    /**
     * 接收前端传递的规格组合参数
     * 参数格式: [{"spe_id": 1, "val_id": 2}, {"spe_id": 2, "val_id": 6}]
     */
    @Operation(summary = "商品规格回传", description = "商品规格回传json")
    @PostMapping("/query")
    public List<Combo> queryCombosBySpecs(@RequestBody List<Map<String, Integer>> specs) {
        return comboService.queryCombosBySpecs(specs);
    }
}